﻿function Submit(workParentId,statusNo) {
    var url = "SendInfo.aspx?WorkParentId=" + workParentId + "&NodeNo=" + statusNo + "&Type=Submit";
    //var url = $(".Submit").attr("href");
    openWin(url, 720, 500);
    return false;
}
function DetailUrl(webName,workParentId,no,i) {
    var url = webName + "?WorkParentId=" + workParentId + "&No=" + no + "&FromPage=" + i;
    //var url = $(this).attr("href");
    openWin(url, 1520, 760);
    return false;
}
function DetailPerson(workParentId, statusNo) {
    var url = "StatusPerson.aspx?WorkParentId=" + workParentId + "&StatusNo=" + statusNo;
    //var url = $(this).attr("href");
    openWin(url, 750, 760);
    return false;
}
function SearchLog(webName,pjId) {
    var url = webName + "?PJId=" + pjId ;
    //var url = $(this).attr("href");
    openWin(url, 1000, 760);
    return false;
}
function UpdatePs(webName, pjId,fromWeb) {
    var url = webName + "?PJId=" + pjId + "&FromWeb=" + fromWeb;
    //var url = $(this).attr("href");
    openWin(url, 1000, 760);
    return false;
}
function Close(workParentId) {
    var url = "Server.ashx?WorkParentId=" + workParentId + "&Type=Close";
    var tr = $("#" + workParentId).parent().parent();
    if (confirm("是否确认关闭此工作流？")) {
        DelTr(url, tr, "工作流序号", "已被关闭");
        return false;
    }
}
function UpLoad(workParentId,no) {
    var url = "../UpDownLoad.aspx?WorkParentId=" + workParentId + "&No=" + no;
    openWin(url, 720, 500);
    return false;
}
function Read(workChildId) {
    var url = "Server.ashx?WorkChildId=" + workChildId + "&Type=Read";
    var img = $("#Read" + workChildId).find('img');
    $.ajax({
        type: "get",
        url: url,
        success: function (data) {
            img.attr('src', 'Images/已读.png');
        }
    });
    return false;
}
function Return(workParentId, workChildId, statusNo,childStatusNo) {
    var url = "ReturnReason.aspx?WorkParentId=" + workParentId + "&WorkChildId=" + workChildId + "&ParentStatusNo=" + statusNo + "&ChildStatusNo=" + childStatusNo + "&Type=Return";
    openWin(url, 720, 500);
    window.location.reload();
    return false;
}
function Pause(workParentId,workChildId,statusNo,childStatusNo) {
    var url = "Server.ashx?WorkParentId=" + workParentId + "&WorkChildId=" + workChildId + "&ParentStatusNo=" + statusNo + "&ChildStatusNo=" + childStatusNo + "&Type=Pause";
    var tr = $("#Pause" + workChildId).parent().parent();
    if (confirm("确认暂停此工作流？")) {
        tr.children(":eq(1)").attr("class", "yellowColor");
        $.ajax({
            type: "get",
            url: url,
            success: function (data) {
                alert("工作流序号" + data + "已被暂停");
            }
        });
    }
    return false;
}

function Pass(workParentId, workChildId, statusNo, childStatusNo, isSingleNode, childNodeNo, nodeCount) {
    var url = "Server.ashx?WorkParentId=" + workParentId + "&WorkChildId=" + workChildId + "&ParentStatusNo=" + statusNo + "&ChildStatusNo=" + childStatusNo + "&IsSingleNode=" + isSingleNode + "&ChildNodeNo=" + childNodeNo + "&NodeCount=" + nodeCount + "&Type=Pass";
    var tr = $("#Pass" + workChildId).parent().parent();
    if (statusNo == nodeCount) {
        if(!confirm("确认提交此工作流？")){
            return false;
        }
    }
    $.ajax({
        type: "Get",
        url: url,
        success: function (data) {
            if (data > 0) {
                tr.remove();
                alert("工作流序号" + data + "已被提交");
                window.location.reload();
                
            } else {
                var workflow = $.parseJSON(data);
                var sendUrl = "SendInfo.aspx?WorkParentId=" + workflow.WorkParentId;
                sendUrl += "&NodeNo=" + workflow.StatusNo;
                openWin(sendUrl, 720, 500);
            }

        }
    });
    return false;
}

//打开新网页
function openWin(u, w, h) {
    var l = (screen.width - w) / 2;
    var t = (screen.height - h) / 2;
    var s = 'width=' + w + ', height=' + h + ', top=' + t + ', left=' + l;
    s += ', toolbar=no, scrollbars=no, menubar=no, location=no, resizable=no';
    open(u, 'oWin', s);
}
//删除被点击的一行
function DelTr(url, tr, x, y) {
    $.ajax({
        type: "Get",
        url: url,
        success: function (data) {
            tr.remove();
            alert(x + data + y);
        }
    });
}


